Dynomotion

Group: DynoMotion Message: 13671 From: Moray Cuthill Date: 8/6/2016
Subject: A little bit C sanity checking please
Attachments :
I've got a minor issue with my lathe, in that during the initialisation occasionally it enables then immediately disables an axis.

After a good few attempts I finally produced the issue with the console open. The problem is that when I activate the axis, it sometimes immediately disables due to following error. I know that's now an easy fix, however it's highlighted that my E-stop monitoring code isn't doing what it should, as it fails to handle an axis being disabled when it shouldn't.

The following bit code should detect it-
 if ((!ch0->Enable || !ch1->Enable) && !INHOMING){
  ClearBit(SYSTEMOK);
  estopMes = ESXZFAIL;
  //printf("X or Z not enabled\n");
 }

Basically if either channel is not enabled, and we're not in homing (axis gets briefly disabled during the homing routine), then an EStop should get triggered.


I've even drawn the logic up in an online logic simulator (http://www.neuroproductions.be/logic-lab/ first one I found via google if anybody is interested), and it works how I think it should.
I'm sure I'm doing something stupid, but I can't figure it out.
I know I could split the logic test out further, but I'm puzzled as to why it won't work in  it's current form.

Thanks,
Moray
  @@attachment@@
Group: DynoMotion Message: 13673 From: TKSOFT Date: 8/6/2016
Subject: Re: A little bit C sanity checking please [1 Attachment]
Hi Moray,

The logic looks ok to me. Is this being continuously executed in a
loop? Maybe post the rest of your code.

Regards
TK


On 2016-08-06 02:15, Moray Cuthill moray.cuthill@...
[DynoMotion] wrote:
> [Attachment(s) from Moray Cuthill included below]
>
> I've got a minor issue with my lathe, in that during the
> initialisation occasionally it enables then immediately disables an
> axis.
>
> After a good few attempts I finally produced the issue with the
> console open. The problem is that when I activate the axis, it
> sometimes immediately disables due to following error. I know that's
> now an easy fix, however it's highlighted that my E-stop monitoring
> code isn't doing what it should, as it fails to handle an axis being
> disabled when it shouldn't.
>
> The following bit code should detect it-
> if ((!ch0->Enable || !ch1->Enable) && !INHOMING){
> ClearBit(SYSTEMOK);
> estopMes = ESXZFAIL;
> //printf("X or Z not enabled\n");
> }
>
> Basically if either channel is not enabled, and we're not in homing
> (axis gets briefly disabled during the homing routine), then an EStop
> should get triggered.
>
> I've even drawn the logic up in an online logic simulator
> (http://www.neuroproductions.be/logic-lab/ first one I found via
> google if anybody is interested), and it works how I think it should.
> I'm sure I'm doing something stupid, but I can't figure it out.
> I know I could split the logic test out further, but I'm puzzled as to
> why it won't work in it's current form.
>
> Thanks,
> Moray
>
Group: DynoMotion Message: 13674 From: Moray Cuthill Date: 8/6/2016
Subject: Re: A little bit C sanity checking please
Hi Tom,

Yes, it runs as part of the main loop.
However, I've just looked at the photo I've got of the console screen when the issue happened, and I've just realised the EStop monitor did catch the fault and trigger an EStop, but an EStop never happened.
My main init.c and the estop.c include files are attached, along with a photo of what appeared in the console.

Once things are initialised and up and running, everything works how it should, as I've bumped the turret of the chuck and an Estop got triggered due to the following error. I can also kill power to either of the servos and an estop gets triggered.
I can't see anything that would cause this.

Thanks,
Moray

On Sat, Aug 6, 2016 at 6:45 PM, tk@... [DynoMotion] <DynoMotion@yahoogroups.com> wrote:
 

Hi Moray,

The logic looks ok to me. Is this being continuously executed in a
loop? Maybe post the rest of your code.

Regards
TK

On 2016-08-06 02:15, Moray Cuthill moray.cuthill@...
[DynoMotion] wrote:
> [Attachment(s) from Moray Cuthill included below]


>
> I've got a minor issue with my lathe, in that during the
> initialisation occasionally it enables then immediately disables an
> axis.
>
> After a good few attempts I finally produced the issue with the
> console open. The problem is that when I activate the axis, it
> sometimes immediately disables due to following error. I know that's
> now an easy fix, however it's highlighted that my E-stop monitoring
> code isn't doing what it should, as it fails to handle an axis being
> disabled when it shouldn't.
>
> The following bit code should detect it-
> if ((!ch0->Enable || !ch1->Enable) && !INHOMING){
> ClearBit(SYSTEMOK);
> estopMes = ESXZFAIL;
> //printf("X or Z not enabled\n");
> }
>
> Basically if either channel is not enabled, and we're not in homing
> (axis gets briefly disabled during the homing routine), then an EStop
> should get triggered.
>
> I've even drawn the logic up in an online logic simulator
> (http://www.neuroproductions. be/logic-lab/ first one I found via
> google if anybody is interested), and it works how I think it should.
> I'm sure I'm doing something stupid, but I can't figure it out.
> I know I could split the logic test out further, but I'm puzzled as to
> why it won't work in it's current form.
>
> Thanks,
> Moray
>


  @@attachment@@
Group: DynoMotion Message: 13690 From: TKSOFT Date: 8/9/2016
Subject: Re: A little bit C sanity checking please [3 Attachments]
Hi Moray,

You didn't include all your code but it looks like you are assuming
INHOMING is a Bit number. So your mistake is you are testing the Bit
number (which is a constant) rather than the Bit's value. Try changing:

if ((!ch0->Enable || !ch1->Enable) && !INHOMING){

to:

if ((!ch0->Enable || !ch1->Enable) && !ReadBit(INHOMING)){


In the C Language any non-zero value is considered as true. Zero is
false. So INHOMING will always be true and !INHOMING will always be
false. So the If condition never be satisfied.

HTH
Regards
TK


On 2016-08-06 12:48, Moray Cuthill moray.cuthill@...
[DynoMotion] wrote:
> [Attachment(s) from Moray Cuthill included below]
>
> Hi Tom,
>
> Yes, it runs as part of the main loop.
> However, I've just looked at the photo I've got of the console screen
> when the issue happened, and I've just realised the EStop monitor did
> catch the fault and trigger an EStop, but an EStop never happened.
> My main init.c and the estop.c include files are attached, along with
> a photo of what appeared in the console.
>
> Once things are initialised and up and running, everything works how
> it should, as I've bumped the turret of the chuck and an Estop got
> triggered due to the following error. I can also kill power to either
> of the servos and an estop gets triggered.
> I can't see anything that would cause this.
>
> Thanks,
> Moray
>
> On Sat, Aug 6, 2016 at 6:45 PM, tk@... [DynoMotion]
> <DynoMotion@yahoogroups.com> wrote:
>
>> Hi Moray,
>>
>> The logic looks ok to me. Is this being continuously executed in a
>> loop? Maybe post the rest of your code.
>>
>> Regards
>> TK
>>
>> On 2016-08-06 02:15, Moray Cuthill moray.cuthill@...
>> [DynoMotion] wrote:
>>> [Attachment(s) from Moray Cuthill included below]
>>
>>>
>>> I've got a minor issue with my lathe, in that during the
>>> initialisation occasionally it enables then immediately disables
>> an
>>> axis.
>>>
>>> After a good few attempts I finally produced the issue with the
>>> console open. The problem is that when I activate the axis, it
>>> sometimes immediately disables due to following error. I know
>> that's
>>> now an easy fix, however it's highlighted that my E-stop
>> monitoring
>>> code isn't doing what it should, as it fails to handle an axis
>> being
>>> disabled when it shouldn't.
>>>
>>> The following bit code should detect it-
>>> if ((!ch0->Enable || !ch1->Enable) && !INHOMING){
>>> ClearBit(SYSTEMOK);
>>> estopMes = ESXZFAIL;
>>> //printf("X or Z not enabled\n");
>>> }
>>>
>>> Basically if either channel is not enabled, and we're not in
>> homing
>>> (axis gets briefly disabled during the homing routine), then an
>> EStop
>>> should get triggered.
>>>
>>> I've even drawn the logic up in an online logic simulator
>>> (http://www.neuroproductions.be/logic-lab/ [1] first one I found
>> via
>>> google if anybody is interested), and it works how I think it
>> should.
>>> I'm sure I'm doing something stupid, but I can't figure it out.
>>> I know I could split the logic test out further, but I'm puzzled
>> as to
>>> why it won't work in it's current form.
>>>
>>> Thanks,
>>> Moray
>>>
Group: DynoMotion Message: 13691 From: Moray Cuthill Date: 8/10/2016
Subject: Re: A little bit C sanity checking please

Hi Tom,

I never thought about including my definitions file, but yes, it's a virtual bit number.

I knew the problem would be something stupidly obvious. I'll get readbit added.

Thanks,
Moray


On 10 Aug 2016 07:57, "tk@... [DynoMotion]" <DynoMotion@yahoogroups.com> wrote:
 

Hi Moray,

You didn't include all your code but it looks like you are assuming
INHOMING is a Bit number. So your mistake is you are testing the Bit
number (which is a constant) rather than the Bit's value. Try changing:

if ((!ch0->Enable || !ch1->Enable) && !INHOMING){

to:

if ((!ch0->Enable || !ch1->Enable) && !ReadBit(INHOMING)){

In the C Language any non-zero value is considered as true. Zero is
false. So INHOMING will always be true and !INHOMING will always be
false. So the If condition never be satisfied.

HTH
Regards
TK

On 2016-08-06 12:48, Moray Cuthill moray.cuthill@...
[DynoMotion] wrote:
> [Attachment(s) from Moray Cuthill included below]
>
> Hi Tom,
>
> Yes, it runs as part of the main loop.
> However, I've just looked at the photo I've got of the console screen
> when the issue happened, and I've just realised the EStop monitor did
> catch the fault and trigger an EStop, but an EStop never happened.
> My main init.c and the estop.c include files are attached, along with
> a photo of what appeared in the console.
>
> Once things are initialised and up and running, everything works how
> it should, as I've bumped the turret of the chuck and an Estop got
> triggered due to the following error. I can also kill power to either
> of the servos and an estop gets triggered.
> I can't see anything that would cause this.
>
> Thanks,
> Moray
>
> On Sat, Aug 6, 2016 at 6:45 PM, tk@... [DynoMotion]
> <DynoMotion@yahoogroups.com> wrote:
>
>> Hi Moray,
>>
>> The logic looks ok to me. Is this being continuously executed in a
>> loop? Maybe post the rest of your code.
>>
>> Regards
>> TK
>>
>> On 2016-08-06 02:15, Moray Cuthill moray.cuthill@...
>> [DynoMotion] wrote:
>>> [Attachment(s) from Moray Cuthill included below]
>>
>>>
>>> I've got a minor issue with my lathe, in that during the
>>> initialisation occasionally it enables then immediately disables
>> an
>>> axis.
>>>
>>> After a good few attempts I finally produced the issue with the
>>> console open. The problem is that when I activate the axis, it
>>> sometimes immediately disables due to following error. I know
>> that's
>>> now an easy fix, however it's highlighted that my E-stop
>> monitoring
>>> code isn't doing what it should, as it fails to handle an axis
>> being
>>> disabled when it shouldn't.
>>>
>>> The following bit code should detect it-
>>> if ((!ch0->Enable || !ch1->Enable) && !INHOMING){
>>> ClearBit(SYSTEMOK);
>>> estopMes = ESXZFAIL;
>>> //printf("X or Z not enabled\n");
>>> }
>>>
>>> Basically if either channel is not enabled, and we're not in
>> homing
>>> (axis gets briefly disabled during the homing routine), then an
>> EStop
>>> should get triggered.
>>>
>>> I've even drawn the logic up in an online logic simulator
>>> (http://www.neuroproductions. be/logic-lab/ [1] first one I found
>> via
>>> google if anybody is interested), and it works how I think it
>> should.
>>> I'm sure I'm doing something stupid, but I can't figure it out.
>>> I know I could split the logic test out further, but I'm puzzled
>> as to
>>> why it won't work in it's current form.
>>>
>>> Thanks,
>>> Moray
>>>